home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 5 / BBS in a Box -Volume V (BBS in a Box) (April 1992).iso / Files / Apple / Apple II TNs(Text).cpt / Apple II TNs(Text) / IIGS / TN.IIGS.035 / TN.IIGS.035
Encoding:
Text File  |  1989-11-15  |  35.5 KB  |  932 lines  |  [TEXT/pdos]

  1. Apple II
  2. Technical Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5. Apple IIGS
  6. #35:    Printer Driver Specifications
  7.  
  8. Revised by:    Matt Deatherage & Suki Lee                      September 1989
  9. Written by:    Dan Hitchens                                          May 1988
  10.  
  11. This Technical Note describes the routines and internal structures needed to 
  12. design a printer driver for the Apple IIGS system, and you should reference it 
  13. in conjunction with the Apple IIGS Toolbox Reference manuals.  An overview and 
  14. associated parameters for each of the printer driver routines are in the Print 
  15. Manager chapter, and you should reference these for a complete picture.
  16. Changed since March 1989:  Added System Software 5.0 calls and the new 
  17. driver structure.
  18. _____________________________________________________________________________
  19.  
  20.  
  21. Printing Modes
  22.  
  23. There are two printing modes:  immediate and deferred.
  24.  
  25.   o  Immediate mode (also known as draft mode), uses the technique of 
  26.      printing immediately.  As you make QuickDraw II calls, you 
  27.      immediately generate commands which cause printing to occur.  This 
  28.      mode is the fastest form of printing, but it can only print 
  29.      characters in the printer's native mode.  (However, the 
  30.      LaserWriter translates the QuickDraw II calls into PostScript 
  31.      calls which can produce high-quality pixelmap images.)
  32.  
  33.   o  Deferred mode (sometimes referred to as spooling), uses the 
  34.      technique of capturing the QuickDraw II calls for each page in a 
  35.      picture file and plays them back at a later time.  To produce 
  36.      high-quality pixelmap images, you must use deferred mode because 
  37.      of the memory constraint of not being able to draw a complete page 
  38.      in memory at one time.  Due to this limitation, we draw a band (a 
  39.      partial page) at a time.  We create a GrafPort which corresponds 
  40.      to the band and play the picture file back, thus causing the saved 
  41.      commands to draw only the images which fall within the band.  Once 
  42.      the pixel image for the band is generated, we can send it to the 
  43.      printer one pixel at a time.
  44.  
  45.  
  46. File Structure
  47.  
  48. The user can install new printer drivers into the system by copying a printer 
  49. driver file into a subdirectory called DRIVERS within the SYSTEM subdirectory.  
  50. The printer driver file must be of type $BB and have an auxiliary type of 
  51. $0001.
  52.  
  53.  
  54. Print Driver Calls
  55.  
  56. A printer driver must support the following calls:
  57.  
  58.     PrDefault               $0913    Sets print record to default
  59.     PrValidate              $0A13    Validates print record
  60.     PrStlDialog             $0B13    Performs a style dialog
  61.     PrJobDialog             $0C13    Performs a job dialog
  62.     PrPixelMap              $0D13    Prints a pixelmap
  63.     PrOpenDoc               $0E13    Opens the document
  64.     PrCloseDoc              $0F13    Closes the document
  65.     PrOpenPage              $1013    Opens a page
  66.     PrClosePage             $1113    Closes a page
  67.     PrPicFile               $1213    Prints a picture file
  68.     --RESERVED--            $1313
  69.     PrError                 $1413    Gets the error value
  70.     PrSetError              $1513    Sets the error value
  71.     GetDeviceName           $1713    Gets device's name
  72.     PrDriverVer             $2313    Gets installed driver version
  73.  
  74. Printer drivers may support the following calls if they use the new driver 
  75. structure outlined below:
  76.  
  77.     PrGetPrinterSpecs       $1813    Returns printer type and 
  78.                                      characteristics
  79.     PrGetPageOrientation    $3813    Returns page orientation
  80.  
  81.  
  82. Print Driver Entry
  83.  
  84.   o  For older drivers, entry is at the first byte (no offset).  For newer 
  85.      (Print Manager 3.0 and later) drivers, the first word is $0000, indicating 
  86.      a new style driver.  The next word is a count of how many calls this driver 
  87.      supports.  All drivers must support the minimum call set.  Additional 
  88.      calls must be supported in the sequence listed (for example, if a driver 
  89.      supports PrGetPageOrientation, it must also support PrGetPrinterSpecs).
  90.   o  The content of the x register is calculated beforehand for use as an index 
  91.      to the correct routine (see the example and note the specific ordering of 
  92.      the routines).
  93.   o  There are two long return addresses (six bytes) that have been pushed onto 
  94.      the stack.  (You must take these addresses into account to access the 
  95.      parameters and to return correctly.)
  96.  
  97. Example
  98.  
  99. StartOfDriver    START
  100.  
  101.                  dc i2 '0'                ; new style driver
  102.                  dc i2 '16'
  103.  
  104.                  jmp (PrDriverList,x)
  105.  
  106.  
  107. PrDriverList     dc a4'PrDefault'
  108.                  dc a4'PrValidate'
  109.                  dc a4'PrStlDialog'
  110.                  dc a4'PrJobDialog'
  111.                  dc a4'PrPixelMap'
  112.                  dc a4'PrOpenDoc'
  113.                  dc a4'PrCloseDoc'
  114.                  dc a4'PrOpenPage'
  115.                  dc a4'PrClosePage'
  116.                  dc a4'PrPicFile'
  117.                  dc a4'InvalidRoutine'
  118.                  dc a4'PrError'
  119.                  dc a4'PrSetError'
  120.                  dc a4'GetDeviceName'
  121.                  dc a4'PrDriverVer'
  122.                  dc a4'PrGetPrinterSpecs'
  123.                  dc a4'PrGetPageOrientation'
  124.  
  125.  
  126. Print Driver Exit
  127.  
  128. You should adjust the stack to use RTL instructions followed by any return 
  129. parameters with the two long return addresses.  To accomplish this, you will 
  130. need to do the following:
  131.  
  132.   o  Eliminate any parameters from the stack which have been passed.
  133.   o  Move the long return addresses so that they are before the space for the 
  134.      returned parameters (if any).
  135.  
  136. Example
  137.  
  138. Figure 1 diagrams the stack just before leaving the print driver:
  139.  
  140.              | Previous Contents
  141.              +---------------------
  142.              | Results (if any)
  143.              +---------------------
  144.              | RTL2 (3 bytes)
  145.              +---------------------
  146.              | RTL1 (3 bytes)
  147.              +---------------------
  148.                                    <--- Stack Pointer
  149.  
  150.  
  151.            Figure 1-Stack Prior to Exiting the Print Driver
  152.  
  153. You should do an RTL with the contents of the flags and registers set 
  154. appropriately.  (See the Return from Call section of the "Using The Apple 
  155. Tools" chapter of the Apple IIGS Toolbox Reference.)
  156.  
  157.  
  158. Print Record Structure
  159.  
  160. Since application programs often need to fiddle with parts of the print record 
  161. (i.e., the values in the style subrecord), we have defined ways for 
  162. applications to interpret the print record, and specifically the style 
  163. subrecord.
  164.  
  165. iDev, the first word of the printer information subrecord, has two defined 
  166. values for third-party printer drivers.  A value of $8001 indicates a dot-
  167. matrix printer while a value of $8003 indicates a laser printer.
  168.  
  169. A value of $8001 indicates that fields of the style subrecord should be 
  170. interpreted as they are by the ImageWriter driver, as documented in the Apple 
  171. IIGS Toolbox Reference.  The first seven bits (0-6) of wDev are defined as for 
  172. the ImageWriter driver.  Bits 7-11 are reserved for Apple's use and must be 
  173. set to zero.  Bits 12-15 may be used by third-party printer drivers as 
  174. necessary; these bits will be set to zero in Apple's drivers.
  175.  
  176. A value of $8003 indicates that fields of the style subrecord should be 
  177. interpreted as they are by the LaserWriter driver.  The first four bits (0-3) 
  178. of wDev are defined as for the LaserWriter driver.  Bits 4-11 are reserved for 
  179. Apple's use and must be set to zero.  Bits 12-15 may be used by third-party 
  180. printer drivers as necessary; these bits will be set to zero in Apple's 
  181. drivers.
  182.  
  183. If an application wishes to take advantages of specific features of a third-
  184. party printer driver, it has to know that it is dealing with that driver.  
  185. Since all drivers will look pretty much alike, the Print Manager allows you to 
  186. ask for the name of the currently selected printer driver.  An application may 
  187. make the Print Manager call PMGetPrinterName, which is documented in this 
  188. Note.  The Print Manager will return the name of the currently selected 
  189. printer in a Pascal (length byte) string.  The name returned is the name of 
  190. the file from which the driver was loaded.  If you intend to use this method 
  191. to identify a driver, you must inform users not to rename the Printer Driver 
  192. file on the boot disk.
  193.  
  194. The PMGetPrinterName call is as follows:
  195.  
  196. Note:  This is a Print Manager call, not a Printer Driver call.  
  197.        It is the only Print Manager call documented in this Note.  
  198.        Printer Drivers do not include this call.
  199.  
  200. PMGetPrinterName         ($2813)
  201.  
  202. Description:
  203.     Returns a Pascal string with the file name of the currently selected 
  204.     printer driver.
  205.  
  206. Passed:
  207.     Longspace            LONG        Space for result
  208.  
  209. Returned:
  210.     NamePointer          LONG        Pointer to a Pascal string of driver 
  211.                                      filename
  212.  
  213.  
  214. Print Driver Calls
  215.  
  216. PrDefault                ($0913)
  217.  
  218. Description:
  219.     Fills the fields of the specified print record with default values for the 
  220.     printer.
  221.  
  222. Passed:
  223.     PrintRecordHandle    LONG        Handle to the print record
  224.  
  225. Returned:
  226.     None
  227.  
  228. Performs the following:
  229.   o  Validates that PrintRecordHandle is a handle and does nothing if not.
  230.   o  Determines the default values for the print record either through tables or 
  231.      calculations.  The default values should take into account such things as 
  232.      paper size and orientation, print mode, printer type, etc.
  233.   o  Copies the default values to the print record specified by the 
  234.      PrintRecordHandle parameter.
  235.  
  236.  
  237. PrValidate               ($0A13)
  238.  
  239. Description:
  240.     Checks the print record to see that it is valid for the currently installed 
  241.     printer driver.
  242.  
  243. Passed:
  244.     PrintRecordHandle    LONG        Handle to the print record
  245.  
  246. Returned:
  247.     ChangeFlag           WORD        Boolean; TRUE if the record is 
  248.                                      adjusted
  249.  
  250. Performs the following:
  251.   o  Checks to see if the print record is from this particular driver.
  252.   o  If the print record is not from this driver, it uses the default values for 
  253.      this driver.
  254.   o  If the print record is from this driver, it makes any changes that might be 
  255.      needed (i.e., style, paper size, etc.).
  256.  
  257.  
  258. PrStlDialog              ($0B13)
  259.  
  260. Description:
  261.     Performs a style dialog with the user.
  262.  
  263. Passed:
  264.     PrintRecordHandle    LONG        Handle to the print record
  265.  
  266. Returned:
  267.     ConfirmFlag          WORD        Boolean; TRUE if the dialog is 
  268.                                      confirmed
  269.  
  270. Performs the following:
  271.   o  Conducts a style dialog with the user to determine the page dimensions and 
  272.      other information needed for page setup (the initial settings of the dialog 
  273.      are derived from the print record).
  274.   o  If the user confirms the dialog, the information from the dialog is saved 
  275.      in the specified print record, PrValidate is called, and the routine 
  276.      returns TRUE.
  277.   o  If the user cancels the dialog, the print record is left unchanged, and the 
  278.      routine returns FALSE.
  279.  
  280. Note:  The following are items typically found in printer style dialogs:
  281.  
  282.   o  Paper Size (US Letter, US Legal, A4 Letter, B5 Letter, International 
  283.      Fanfold)
  284.   o  Printing Orientation (Landscape, Portrait)
  285.   o  Vertical Sizing (Normal, Intermediate, Condensed)
  286.   o  Special Effects:
  287.        Font Effects (Font Substitution, Smoothing)
  288.        Reduction or Enlargement
  289.        Gaps or No Gaps between pages
  290.  
  291. Every printer style dialog should have an OK button (default) and a Cancel 
  292. button.
  293.  
  294.  
  295. PrJobDialog              ($0C13)
  296.  
  297. Description:
  298.     Performs a job dialog with the user.
  299.  
  300. Passed:
  301.     PrintRecordHandle    LONG        Handle to the print record
  302.  
  303. Returned:
  304.     ConfirmFlag          WORD        Boolean; True if the dialog is 
  305.                                      confirmed
  306.  
  307. Performs the following:
  308.   o  Conducts a job dialog with the user to determine the print quality, range 
  309.      of pages to print, and other specifications.  The initial settings are 
  310.      derived from the previous PrJobDialog call (or initial default values) 
  311.      except the page range which is set to ALL, and the number of copies which 
  312.      is set to ONE.
  313.   o  If the user confirms the dialog, PrValidate is called, the print record is 
  314.      updated, and the routine returns TRUE.
  315.   o  If the user cancels the dialog, the print record is left unchanged, and the 
  316.      routine returns FALSE.
  317.  
  318. Note:  The following are items typically found in printer job dialogs:
  319.  
  320.   o  Print Quality (Best, Faster, Draft, etc.)
  321.   o  Color option
  322.   o  Pages (All, Range)
  323.   o  Copies
  324.   o  Paper Source (paper cassette, manual feed)
  325.  
  326. Every printer job dialog should have an OK button (default) and a Cancel 
  327. button.
  328.  
  329.  
  330. PrPixelMap               ($0D13)
  331.  
  332. Description:
  333.     Prints all or part of the specified pixelmap.
  334.  
  335. Passed:
  336.     srcLocPtr            LONG        Pointer to the source LocInfo which
  337.                                      contains the pointer to the pixelmap.
  338.     srcRectPtr           LONG        Pointer to the rectangle which
  339.                                      encloses the pixelmap to be printed.
  340.     colorFlag            WORD        Boolean; FALSE if black and white,
  341.                                      TRUE if color.
  342.  
  343. Returned:
  344.     None
  345.  
  346. Performs the following:
  347.   o  Calls DevIsItSafe (port driver call) to verify that the port it functioning 
  348.      and it is safe to proceed.  If it is not functioning, set the internal 
  349.      error code to $1302 (Port Not On) and return with an error status.
  350.   o  Saves the current port.
  351.   o  Turns on the watch cursor to signal the user that it will take some time.
  352.   o  Clears the internal error code (default, if no errors occur).
  353.   o  Gets a new handle for a print record and set it to the defaults by calling 
  354.      PrDefault.
  355.   o  If colorFlag is set, sets bit 5 of wdev in prStl of the print record.
  356.   o  Do any initialization that might be needed by the driver.
  357.   o  Determine the intersection of the two rectangles (rectangle pointed to by 
  358.      srcRectPtr and the pixelmap's boundary rectangle from srcLocPtr) and if 
  359.      there is no intersection, then nothing is to be printed.
  360.   o  Print the pixel image which is within the intersection of the two 
  361.      rectangles.
  362.   o  Cause a page eject to occur on the printer.
  363.   o  Do any clean up that is needed.
  364.   o  Turn off the watch cursor by calling InitCursor.
  365.   o  Restore the port by calling SetPort.
  366.  
  367.  
  368. PrOpenDoc                ($0E13)
  369.  
  370. Description:
  371.     This routine initializes the things needed to open a document.  In deferred 
  372.     mode, it establishes a GrafPort and makes it the current port for printing.
  373.  
  374. Passed:
  375.     PrintRecordHandle    LONG        Handle to the print record
  376.     PrinterPortPtr       LONG        Pointer to the GrafPort, if desired,
  377.                                      zero to allocate a new GrafPort
  378. Returned:
  379.     PrinterPortPtrRet    LONG        Pointer to the GrafPort if the
  380.                                      PrinterPortPtr was zero
  381.  
  382. Performs the following:
  383.   o  Calls DevIsItSafe (port driver call) to verify that the port is functioning 
  384.      and it is safe to proceed.
  385.   o  Turns on the watch cursor to signal the user that it will take some time.
  386.   o  Validates the print record passed by  calling PrValidate.
  387.   o  Clears the internal error code (default, if nothing happens).
  388.   o  Puts up a dialog indicating that printing is occurring (or preparing to 
  389.      print).
  390.   o  If the user needs a GrafPort, create one and internally note that one was 
  391.      created (PrCloseDoc will need to know that one was created here).
  392.   o  Initializes parameters (i.e., page number, document number, etc.).
  393.   o  If deferred mode, create an initial page list (an array of handles to 
  394.      pictures) for 20 pages (arbitrary number to start).
  395.   o  Do other initialization that might be needed to start a print job.
  396.  
  397. Possible errors:
  398.                          $1302       Indicates Port Not On
  399.  
  400.  
  401. PrCloseDoc               ($0F13)
  402.  
  403. Description:
  404.     Closes the GrafPort being used for printing.  For immediate mode, this 
  405.     routine ends the printing job.  For deferred mode, this routine ends the 
  406.     process allowing the job to be printed.
  407.  
  408. Passed:
  409.     PrintGrafPortPtr     LONG        Pointer to the GrafPort used for printing
  410.  
  411. Returned:
  412.     None
  413.  
  414. Performs the following:
  415.   o  Checks that the last print driver call did not cause a Port Not On error.  
  416.      If the error occurred, do nothing and return.
  417.   o  Call ClosePort (port driver call) to close the port.
  418.   o  If the driver allocated a GrafPort in PrOpenDoc, dispose of it.
  419.   o  If in immediate mode, do what is needed to shut things down.
  420.   o  Takes down the information dialog box from PrOpenDoc.
  421.  
  422.  
  423. PrOpenPage               ($1013)
  424.  
  425. Description:
  426.     Begins a new page only if the page falls within the page range specified in 
  427.     the job subrecord.
  428.  
  429. Passed:
  430.     PrintGrafPortPtr     LONG        Pointer to the GrafPort used for printing
  431.     PageFramePtr         LONG        Pointer to the scaling parameter,
  432.                                      zero for none.
  433. Returned:
  434.     None
  435.  
  436. Performs the following:
  437.   o  Looks at the driver's internal error value, and if an error has occurred, 
  438.      it returns without doing anything.
  439.   o  Increments the page number.
  440.   o  Calls SetPort to make the specified port the current port.
  441.   o  Initializes the port and zeroes the boundary rectangle so no actual drawing 
  442.      will occur.
  443.   o  If immediate mode, then do the following:
  444.        If this page is to be printed, install immediate mode procedures by 
  445.        doing the following:
  446.          o  Create a procedure table (get the standard procedures. from 
  447.             SetStdProcs).
  448.          o  Put pointers to your procedures into the table and call the
  449.             QuickDraw II routine SetGrafProcs.  This will cause QuickDraw
  450.             II calls to print instead of writing to the GrafPort.
  451.   o  If deferred mode, then do the following:
  452.        o  If the current page is out of the page range, then return without 
  453.           doing anything further.
  454.        o  If the user passes his own PageFramePtr , then get it.
  455.        o  Open a picture by calling OpenPicture and adding its handle to
  456.           the page list array described in PrOpenDoc.
  457.        o  Set the ClipRgn and VisRgn to the sizing framing rectangle
  458.           specified by PageFramePtr , or if none was specified, to the
  459.           default of rPage.
  460.  
  461. PrClosePage              ($1113)
  462.  
  463. Description:
  464.     This signals the end of a page.
  465.  
  466. Passed:
  467.     PrintGrafPortPtr     LONG        Pointer to the GrafPort used for printing
  468.  
  469. Returned:
  470.     None
  471.  
  472. Performs the following:
  473.   o  Looks at the driver's internal error value and if a Port Not On error has 
  474.      occurred, it returns without doing anything.
  475.   o  If immediate mode, do the following:
  476.   o  If the current page is within the range of pages to be printed, then 
  477.      cause a form feed (unless no gap was specified).
  478.   o  If deferred mode, do the following:
  479.   o  If there was no picture generated, then do nothing and just return.
  480.   o  Call SetPort to make the specified port the current port.
  481.   o  Do a ClosePicture to close the picture.
  482.  
  483.  
  484. PrPicFile                ($1213)
  485.  
  486. Description:
  487.     Prints a picture file generated in deferred mode.
  488.  
  489. Passed:
  490.     PrintRecordHandle    LONG        Handle to the print record
  491.     PrintGrafPortPtr     LONG        Pointer to the GrafPort used for printing
  492.     StatusRecPtr         LONG        Pointer to the printer status record
  493.  
  494. Returned:
  495.     None
  496.  
  497. Performs the following:
  498.   o  Looks at the driver's internal error value and if a Port Not On error has 
  499.      occurred, it returns without doing anything.
  500.   o  If immediate mode, return without doing anything.
  501.   o  If deferred mode, then do the following:
  502.   o  If the error code is not zero (errors) then dispose of everything.
  503.   o  Put up an information dialog indicating that printing is occurring.
  504.   o  If PrintGrafPortPtr is NIL, create one and make a note of it.
  505.   o  Call OpenPort to make the GrafPort the current port.
  506.   o  If StatusRecPtr is NIL, use an internal one.
  507.   o  Initialize the status record and the number of copies counter.
  508.   o  If the idle proc in the print record is NIL, point to an internal one.
  509.   o  Do The Following For Each Copy:
  510.        o  Calculate the number of bands it will take to print one page
  511.           and initialize the page counter.
  512.        o  Do The Following For Each Page:
  513.             o  Call the idle procedure routine and initialize the
  514.                band counter.
  515.             o  Get the handle to the picture associated with the
  516.                current page.
  517.             o  Set the dirty flag in the status record to FALSE.
  518.             o  If manual paper feed, put up a dialog and wait for
  519.                a response.
  520.             o  Do The Following For Each Band:
  521.                  o  Call the idle procedure.
  522.                  o  Calculate the band rectangle and update
  523.                     icurband with the current band number.
  524.                  o  Call the idle proc again.
  525.                  o  Set the imaging flag in the status record to TRUE.
  526.                  o  Call InitPort to reinitialize the port.
  527.                  o  Adjust fields in the port to cause drawing into
  528.                     the band buffer.
  529.                  o  Adjust fields in the location information field
  530.                     of the status record and calculate the sizing rectangle.
  531.                  o  Calculate the boundary rectangle for the band and set
  532.                     the port rectangle to it.
  533.                  o  Set the ClipRgn and the VisRgn to the sizing rectangle.
  534.                  o  Initialize the band by filling it with white space.
  535.                  o  Call DrawPicture to draw the picture into the band's
  536.                     rectangle.
  537.                  o  Do whatever is needed to print the pixel image in the
  538.                     band's rectangle.
  539.                  o  Clear the imaging flag.
  540.                  o  Calculate the next band's position.
  541.                  o  Increment the band's counter and loop back if not done.
  542.             o  If GAP was specified, cause a form feed.
  543.             o  Increment the page count to the next page and loop back
  544.                if not done.
  545.        o  Increment the number of copies counter and loop back if not done.
  546.   o  Free any buffers that you own and close the port.
  547.   o  Dispose of the information dialog that you put up.
  548.   o  Dispose of each picture in the picture list by calling KillPicture.
  549.   o  Dispose of the picture list itself.
  550.   o  Reset the cursor.
  551.  
  552.  
  553. PrError                  ($1413)
  554.  
  555. Description:
  556.     Gets the error code from the last Print Manager call.
  557.  
  558. Passed:
  559.     None
  560.  
  561. Returned:
  562.     LastError            WORD        Result code from last Print Manager call
  563.  
  564. Performs the following:
  565.   o  Gets the driver's internal error value (which was determined by the last 
  566.      driver call) and sets the return parameter LastError to it.
  567.  
  568. Possible Errors:
  569. noError                  $0000
  570. PrAbort                  $0080       Indicates print job was aborted
  571.                          $1301       Indicates missing drivers
  572.                          $1302       Indicates Port Not On
  573.                          $1303       Indicates No Print Record
  574.                          $1306       Indicates PAP Connection Not Made
  575.                          $1307       Indicates Read/Write PAP Error
  576.                          $1308       Indicates Printer Connection Failed
  577.  
  578.  
  579. PrSetError               ($1513)
  580.  
  581. Description:
  582.     Sets the error value.
  583.  
  584. Passed:
  585.     ErrorNumber          WORD        Error number to be set
  586.  
  587. Returned:
  588.     None
  589.  
  590. Performs the following:
  591.   o  Sets the driver's internal error value to the value of the passed 
  592.      ErrorNumber parameter.
  593.  
  594.  
  595. GetDeviceName            ($1713)
  596.  
  597. Description:
  598.     Used as a communications tool between the printer driver and port driver.
  599.  
  600. Passed:
  601.     None
  602.  
  603. Returned:
  604.     None
  605.  
  606. Performs the following:
  607.   o  Calls the port driver routine PrDevPrChanged with the printer name as 
  608.      input.  This is necessary for drivers that will work over AppleTalk.  The 
  609.      name passed as the parameter to PrDevPrChanged should be what AppleTalk 
  610.      will use in an NBPLookup situation; for AppleTalk, such a name should 
  611.      follow NBP conventions.
  612.  
  613.  
  614. PrDriverVer              ($2313)
  615.  
  616. Description:
  617.     Returns the version number of the currently installed printer driver.
  618.  
  619. Passed:
  620.     Wordspace            WORD        Space for results
  621.  
  622. Returned:
  623.     versionInfo          WORD        Printer driver's version number
  624.  
  625. Performs the following:
  626.   o  Gets the internal version number of the printer driver and returns it on 
  627.      the stack at versionInfo.
  628.  
  629. Note:  The internal version number is stored 
  630.        major byte, minor byte (i.e., $0103 represents version 1.3)
  631.  
  632.  
  633. PrGetPrinterSpecs        ($1813)
  634.  
  635. Description:
  636.     Returns the type of printer and the printer's characteristics.
  637.  
  638. Passed:
  639.     Wordspace            WORD        Space for results
  640.     Wordspace            WORD        Space for results
  641.  
  642. Returned:
  643.     PrinterType          WORD        0 = undefined
  644.                                      1 = ImageWriter or ImageWriter II
  645.                                      2 = ImageWriter LQ
  646.                                      3 = LaserWriter family (except IISC)
  647.                                      4 = Epson
  648.                                      $8001 = generic dot matrix printer
  649.                                      $8003 = generic laser printer
  650.     PrCharacteristics    WORD        Bits 15 - 2 = reserved, must be zero
  651.                                      Bits 1-0:     00 = cannot determine
  652.                                                    01 = black and white 
  653.                                                         only
  654.                                                    10 = color capable
  655.  
  656. Performs the following:
  657.   o  Returns characteristics intrinsic for the printer being supported.
  658.  
  659.  
  660. PrGetPgOrientation       ($3813)
  661.  
  662. Description:
  663.     Returns the page orientation from the current print record.
  664.  
  665. Passed:
  666.     Wordspace            WORD        Space for results
  667.  
  668. Returned:
  669.     PgOrientation        WORD        Current page orientation:
  670.                                      0 = portrait
  671.                                      1 = landscape
  672.  
  673. Performs the following:
  674.   o  Returns the page orientation from the current page setup information in the 
  675.      print record.
  676.  
  677.  
  678. Immediate Mode Procedures
  679.  
  680. To print in the immediate mode, you need to install procedures which will 
  681. cause printing when you make QuickDraw II calls (as noted in PrOpenPage).  
  682. This section describes the structure and parameters for these routines.
  683.  
  684. To install the immediate mode procedures, first create a procedure table for 
  685. sixteen entries (16*4 bytes) and fill it with the standard procedures by 
  686. calling SetStdProcs.  Once you have the standard procedures, install the 
  687. addresses of your procedures into it and call SetGrafProcs.  Installing your 
  688. procedure addresses will cause the appropriate QuickDraw II calls to call your 
  689. procedures, which, in turn, will perform the actual printing.
  690.  
  691. The routines that need to be written are known as QuickDraw II "bottleneck 
  692. procedures."  Access to the routines are from bank $E0 (accessed by doing a 
  693. JSL to the appropriate address in bank $E0).  When you call any of the 
  694. bottleneck procedures, the first direct page of QuickDraw II is active and the 
  695. following direct page locations are valid:
  696.  
  697.     PortRef      $24
  698.     MaxWidth     $20
  699.     MasterSCB    $08
  700.     UserId       $0A
  701.  
  702. Two bottleneck procedures, StdText and StdPixels, are of most concern when 
  703. writing immediate mode procedures.  (Refer to Apple IIGS Technical Note #34 
  704. for more information on bottleneck procedures.)
  705.  
  706. The routine StdText (standard text) is the standard text drawing routine.  To 
  707. install this routine into your procedure table (as described above), make it 
  708. the first entry (offset of $00).  Once it's installed, you can access it by 
  709. doing a long call to absolute address $E01E04.  Its direct page parameters are 
  710. as follows:
  711.  
  712.     DrawVerb      $38    Describes the kind of text to draw.  There 
  713.                          are three possible values:
  714.                              DrawCharVerb    0
  715.                              DrawTextVerb    1
  716.                              DrawCStrVerb    2
  717.     TextPtr       $DA    If the draw verb is DrawTextVerb or 
  718.                          DrawCStrVerb, TextPtr points to the text 
  719.                          buffer or C string to draw.
  720.     TextLength    $D8    If the draw verb is DrawTextVerb, 
  721.                          TextLength contains the number of bytes in 
  722.                          the text buffer.
  723.     CharToDraw    $D6    If the draw verb is DrawCharVerb, 
  724.                          CharToDraw contains the character to draw.
  725.  
  726. The routine StdPixels is the standard pixelmap drawing routine.  To install 
  727. this routine into your procedure table (as described above), put it at offset 
  728. $20.  Once it's installed, you can access it by doing a long call to absolute 
  729. address $E01E24.  Its direct page parameters are as follows:
  730.  
  731.     SrcLocInfo    $CC    The LocInfo record for the source pixel 
  732.                          map
  733.     DestLocInfo   $0C    The LocInfo record for the destination 
  734.                          pixel map
  735.     SrcRect       $DC    The source rectangle for the operation in 
  736.                          local coordinates for the source pixel map 
  737.                          (as described in the source LocInfo 
  738.                          record)
  739.     DestRect      $1C    The destination rectangle for the 
  740.                          operation in local coordinates for the 
  741.                          destination pixel map (as described in the 
  742.                          destination  LocInfo record)
  743.     XferMode      $E4    The mode to use for data transfer
  744.     RgnHandleA    $50    The handle to the first region to which 
  745.                          drawing is clipped (usually the ClipRgn 
  746.                          from the GrafPort)  A NIL handle is not 
  747.                          allowed.  To signify no clipping, pass a 
  748.                          handle to the WideOpen region, which is 
  749.                          defined as 10 bytes:
  750.  
  751.                          Length      $A       (word)
  752.                          -MaxInt    -$3FFF    (word)
  753.                          -MaxInt    -$3FFF    (word)
  754.                          +MaxInt    +$3FFF    (word)
  755.                          +MaxInt    +$3FFF    (word)
  756.  
  757.     RgnHandleB    $60    The handle to the second region to which 
  758.                          drawing is clipped (usually the VisRgn 
  759.                          from the GrafPort)  A NIL handle is not 
  760.                          allowed.  To signify no clipping, pass a 
  761.                          handle to the WideOpen region.
  762.     RgnHandleC    $70    The handle to the second region to which 
  763.                          drawing is clipped (usually the mask 
  764.                          region from the CopyPixels or the 
  765.                          PaintPixels call)  A NIL handle is not 
  766.                          allowed.  To signify no clipping, pass a 
  767.                          handle to the WideOpen region.
  768.  
  769.  
  770. Example:
  771.  
  772. ;*****************************************************************
  773. ;** Example of Immediate Mode Printer Procedures.               **
  774. ;*****************************************************************
  775.  
  776. Immedprocs    Start
  777.  
  778. SrcRect       equ $DC
  779. SrcLocInfo    equ $CC
  780. DrawVerb      equ $38
  781. TextPtr       equ $da
  782. TextLength    equ $d8
  783. CharToDraw    equ $d6
  784.  
  785. ;------------------------------------------------------------------
  786. ;
  787. ; _StdPixels Procedure (Prints Pixelmaps)
  788. ;
  789. ;------------------------------------------------------------------
  790. Pixel         Entry
  791.  
  792.               phb                  ;save data bank reg on stack
  793.               phk                  ;get program bank reg.
  794.               plb                  ;use as data bank reg.
  795.  
  796.               lda iPrErr           ;get errors
  797.               beq Continue         ;branch if none
  798.               brl ExitPixel        ;branch if errors
  799.  
  800. Continue      anop
  801. ;This gets the source rectangle and stores it at PixelRect
  802.               ldx #6
  803. MoveSrc       lda SrcRect,x
  804.               sta PixelRect,x
  805.               dex
  806.               dex
  807.               bpl MoveSrc
  808.  
  809. ;This gets the source LocInfo and stores it at PixelLoc 
  810.               ldx #16-2
  811. MoveLI        lda SrcLocInfo,x
  812.               sta PixelLoc,x
  813.               dex
  814.               dex
  815.               bpl MoveLI
  816.  
  817.               pushptr PixelLoc     ;push pointer to LocInfo
  818.               pushptr PixelRect    ;push pointer to rectangle
  819.  
  820. ;++++++++++++++++++++++
  821. ; Insert code here to print a pixelmap
  822. ;    INPUT:    PixelLoc     LONG, Pointer to pixel LocInfo
  823. ;              PixelRect    LONG, Pointer to pixels BoundsRect
  824. ;           SP->
  825. ;++++++++++++++++++++++
  826.  
  827. Exitpixel     lda #0               ;return with no errors
  828.               clc
  829.               plb                  ;restore data bank
  830.               rtl                  ;returnith long
  831.     
  832. PixelLoc      ds 16                ;pixel LocInfo
  833. PixelRect     ds 8                 ;pixel rectangle
  834.  
  835.  
  836. ;------------------------------------------------------------------
  837. ;
  838. ; _StdText Procedure (Prints Standard Text)
  839. ;
  840. ;------------------------------------------------------------------
  841. StdText       Entry
  842.  
  843.               phb                  ;save data bank reg on stack
  844.               phk                  ;get program bank reg. 
  845.               plb                  ;use as data bank reg.
  846.  
  847.               pushptr PenPos
  848.               _GetPen              ;current pen pos. -> PenPos
  849.  
  850. ;++++++++++++++++++++++
  851. ; Insert Code Here to move the printers head to the corresponding
  852. ; PenPos position (if needed).
  853. ;++++++++++++++++++++++
  854.  
  855.               pushword #0          ;space for textwidth
  856.                                    ;(for call to _TextWidth)
  857.  
  858.               lda DrawVerb         ;get DrawVerb
  859.               beq DoCar            ;if DrawVerb=0 then DoCar
  860.  
  861.               cmp #1
  862.               beq Dotext2          ;if DrawVerb=1 then Dotext2
  863. ;
  864. ;We get here if it's a "C" string (DrawVerb=2)
  865. ;
  866. DoCstring     anop
  867.               sep #$20
  868.               longa off
  869. ;Search down through string looking for terminator to calc. length
  870.               ldy #0
  871. KeepLooking   lda [TextPtr],y
  872.               beq TheEnd
  873.               iny
  874.               bra KeepLooking
  875. TheEnd        rep #$20
  876.               longa on
  877.               lda TextPtr+2
  878.               pha                  ;push the pointer to string
  879.               lda Textptr
  880.               pha
  881.               phy                  ;push the length of sting
  882.               bra Common
  883. ;
  884. ;We get here if it's just one character (DrawVerb=0)
  885. ;
  886. DoCar         anop
  887.               pushword #0
  888.               tdc
  889.               clc
  890.               adc #CharToDraw      ;calculate addr. of char.
  891.               pha                  ;push addr. of character
  892.               pushword #1          ;push length of one char.
  893.               bra Common
  894. ;
  895. ;We get here if it's a string of text (DrawVerb=1)
  896. ;
  897. DoText2       anop
  898.               lda TextPtr+2
  899.               pha                  ;push pointer to the string
  900.               lda Textptr
  901.               pha
  902.               lda TextLength
  903.               pha                  ;push the strings length
  904. Common        lda 5,s              ;Dup the last 3 words of
  905.               pha                  ;the stack (for _TextWidth)
  906.               lda 5,s
  907.               pha
  908.               lda 5,s
  909.               pha
  910. ;++++++++++++++++++++++
  911. ; Insert code here to print the text
  912. ;
  913. ;    INPUT:    TextPointer    LONG, Pointer to text to print
  914. ;              TextLength     WORD, No. of bytes to print
  915. ;          SP->
  916. ;++++++++++++++++++++++
  917.               _TextWidth           ;get the texts width (DH)
  918.               pushword #0          ;set (DV)=0
  919.               _Move                ;move current pen location
  920.  
  921. ExitText      lda #0               ;return with no errors
  922.               clc
  923.               plb                  ;restore data bank
  924.               rtl                  ;returnith long
  925.  
  926. PenPos        ds 4                 ;pen position
  927.               end
  928.  
  929.  
  930. Further Reference
  931. _____________________________________________________________________________
  932.   o  Apple IIGS Toolbox Reference, Volumes 1 & 2